home *** CD-ROM | disk | FTP | other *** search
/ Apple II Magazines (PO) / Nibble Volume 09, No. 04 (1988-04)(MicroSPARC)(Side A).zip / Nibble Volume 09, No. 04 (1988-04)(MicroSPARC)(Side A).po / EDITOR.OBJ.S < prev    next >
Text File  |  1996-12-24  |  13KB  |  521 lines

  1. *______________________*
  2. *                      *
  3. *     Proportional     *
  4. *      PrintWorks      *
  5. *                      *
  6. *    Editor  Module    *
  7. *      EDITOR.OBJ      *
  8. *______________________*
  9. *                      *
  10. *      Written by      *
  11. *     Bob Thrasher     *
  12. *  Copyright (C) 1987  *
  13. *  by MicroSPARC, INC  *
  14. *  Concord, MA  01742  *
  15. *______________________*
  16. *                      *
  17. *     Created with     *
  18. *      Merlin Pro      *
  19. *______________________*
  20. *                      *
  21.  
  22.           ORG $8000
  23.  
  24. ZPage1    EQU $00        ;Temp. zero page pointer
  25. ZPage2    EQU $02        ; "
  26. EndProp   EQU $04        ;End of proportional set
  27. COUTChar  EQU $06        ;Parameter passer
  28.  
  29.           DUM $300       ;User accessable parameter table
  30. COUTVert  DS 1
  31. COUTHorL  DS 1
  32. COUTHorH  DS 1
  33. LeadingV  DS 1
  34. LeadingH  DS 1
  35. InvFlag   DS 1
  36. SPCWidth  DS 1
  37. PrintFlg  DS 1
  38. PageNum   DS 1
  39. FontNum   DS 1
  40. JMPCout   DS 4
  41. JMPHome   DS 3
  42. JMPGetK   DS 3
  43. FontSets  DS 2
  44. Temp1     DS 1
  45. Temp2     DS 1
  46. Temp3     DS 1
  47. Temp4     DS 1
  48. Index1    DS 1
  49. Counter1  DS 1
  50. DisTable  DS 8
  51.           DEND
  52. YHiresL   EQU $9480      ;HIRES lookup tables
  53. YHiresH   EQU $9540
  54. Table1    EQU $7000      ;     (Width Table)
  55. Table2    EQU Table1+$60 ;     (Location pointers)
  56. Table3    EQU Table2+$C0 ;     (Actual data)
  57. Table3b   EQU $6000      ;     (Char data: 8 byte)
  58.  
  59. * A couple of macros for conciseness and ease of reading.
  60.  
  61. Mov       MAC
  62.           LDA ]1
  63.           STA ]2
  64.           <<<
  65. Set       MAC
  66.           Mov #<]2       ;]1
  67.           Mov #>]2       ;]1+1
  68.           <<<
  69. Add       MAC
  70.           LDA ]2
  71.           CLC
  72.           ADC ]1
  73.           STA ]2
  74.           <<<
  75.  
  76.           EXP OFF
  77.  
  78. * A jump table for access to all routines from BASIC.
  79.  
  80.           JMP Convert
  81.           JMP Clear
  82.           JMP CreateN
  83.           JMP UpVert
  84.           JMP Inverse
  85.           JMP Upside
  86.           JMP ShowSet
  87.           JMP Magnify
  88.           JMP Cursor
  89.           JMP Toggle
  90.  
  91. * Convert - This routine takes the non-proportional
  92. *           character set at (Table3b) and through a
  93. *           series of calculations transforms it into
  94. *           a proportional font stored at (Table1).
  95.  
  96. Convert   Set ZPage1     ;Table3b ;Point ZPage1 to actual data
  97.           Mov #$00       ;Index1 ;Point Index1 to width table
  98.           Mov #$5F       ;Counter1 ;Total of $5F characters
  99. :1        Mov #$00       ;Temp1 ;Variable to check for blanks
  100.           LDY #$07       ;Index through bytes of char
  101. :2        LDA (ZPage1),Y ;Get a byte
  102.           AND #$7F       ;Remove high bit
  103.           STA (ZPage1),Y ;Replace in set
  104.           ORA Temp1      ;Mask onto running counter
  105.           STA Temp1
  106.           DEY            ;Do all 8 bytes for each char
  107.           BPL :2
  108. :3        LDA Temp1      ;First check for a blank
  109.           BEQ :5         ;Yes, so skip ahead
  110.           AND #$01       ;Is char already left justified?
  111.           BNE :5         ;Yes, so skip ahead
  112.           Mov #$00       ;Temp1 ;Now begin left shifting
  113.           LDY #$07       ;(all 8 bytes in sync)
  114. :4        LDA (ZPage1),Y ;Get a byte
  115.           LSR            ;Shift it left
  116.           STA (ZPage1),Y ;Replace in set
  117.           ORA Temp1      ;Again a running mask
  118.           STA Temp1
  119.           DEY            ;Do all 8
  120.           BPL :4
  121.           BMI :3
  122. :5        LDX #$07       ;Now determine width
  123.           Mov #$00       ;Temp1 ;Another temp mask variable
  124.           LDY #$07       ;Must check all 8 bytes
  125. :6        LDA (ZPage1),Y ;Get a byte
  126.           ORA Temp1      ;Overlay with mask
  127.           STA Temp1
  128.           DEY            ;Do them all
  129.           BPL :6
  130.           Mov #$40       ;Temp2 ;Start checking from right
  131. :7        LDA Temp2
  132.           AND Temp1      ;Is there a pixel present here?
  133.           BNE :8         ;Yes, so the length is X-REG
  134.           ROR Temp2      ;No, so shift left 1 pixel
  135.           DEX            ;Width decreases
  136.           BNE :7         ;And let's keep checking
  137. :8        TXA
  138.           LDX Index1     ;Point to width table
  139.           STA Table1,X   ;Place this width in table
  140.           Add #$08       ;ZPage1 ;Move ZPage1 to next char
  141.           BCC :9
  142.           INC ZPage1+1
  143. :9        INC Index1     ;Move to next width position
  144.           DEC Counter1   ;Finished with all $5F chars?
  145.           BPL :1         ;No, so keep going
  146.           Set ZPage1     ;Table3b;Set ZPage1 to Non-prop table
  147.           Set ZPage2     ;Table3 ;Set ZPage2 to Prop table
  148.           Mov #$00       ;Counter1 ;Start at first char in table
  149. Convert1  LDX Counter1
  150.           LDA Table1,X   ;Get width
  151.           BEQ :5         ;If 0 then don't create data
  152.           STA Temp4      ;Save width
  153.           TXA
  154.           ASL
  155.           TAX
  156.           LDA ZPage2
  157.           SEC
  158.           SBC #<Table1
  159.           STA Table2,X   ;Create index entry for data loc
  160.           INX
  161.           LDA ZPage2+1
  162.           SBC #>Table1
  163.           STA Table2,X
  164.           Mov #$01       ;Temp1 ;Start at left side of char
  165. :1        Mov #$80       ;Temp2 ;Start at bottom w/ new data
  166.           Mov #$00       ;Temp3 ;Zero the temp data byte
  167.           LDY #$07       ;Eight bytes to be scanned
  168. :2        LDA (ZPage1),Y ;Get the byte from non-prop set
  169.           AND Temp1      ;Is this bit set?
  170.           BEQ :3         ;No, so don't set a bit in data
  171.           LDA Temp2      ;Set a data bit
  172.           ORA Temp3
  173.           STA Temp3
  174. :3        LSR Temp2      ;Shift one bit upward
  175.           DEY            ;Do all 8 bytes
  176.           BPL :2
  177.           INY
  178.           Mov Temp3      ;(ZPage2),Y ;Put byte into final table
  179.           INC ZPage2     ;Move to next location
  180.           BNE :4
  181.           INC ZPage2+1
  182. :4        ASL Temp1      ;Now move rightward to next byte
  183.           DEC Temp4      ;Decrement width loop register
  184.           BNE :1
  185. :5        Add #$08       ;ZPage1 ;Move ahead to next char
  186.           BCC :6
  187.           INC ZPage1+1
  188. :6        INC Counter1   ;Go until all chars processed
  189.           LDA Counter1
  190.           CMP #$60
  191.           BNE Convert1
  192.           Mov ZPage2     ;EndProp
  193.           Mov ZPage2+1   ;EndProp+1
  194.           RTS
  195.  
  196. * Clear - This section merely clears memory from
  197. *         $6000-$7FFF for initialization.
  198.  
  199. Clear     Mov #$20       ;Temp1
  200.           Mov #$60       ;ZPage1+1
  201.           Mov #$00       ;ZPage1
  202.           TAY
  203. :1        STA (ZPage1),Y
  204.           DEY
  205.           BNE :1
  206.           INC ZPage1+1
  207.           DEC Temp1
  208.           BNE :1
  209.           RTS
  210.  
  211. * CreateN - This code takes the character set displayed
  212. *           on-screen and creates a non-proportional
  213. *           character set at (Table3b)
  214.  
  215. CreateN   Mov #$00       ;Temp1
  216.           STA Temp2
  217.           STA Temp3
  218.           Set ZPage1     ;Table3b
  219. :1        Mov Temp3      ;Temp4
  220.           LDX #$07
  221. :2        LDY Temp4
  222.           LDA YHiresL,Y
  223.           CLC
  224.           ADC Temp2
  225.           STA ZPage2
  226.           Mov YHiresH,Y  ;ZPage2+1
  227.           LDY #$00
  228.           Mov (ZPage2),Y ;(ZPage1),Y
  229.           INC ZPage1
  230.           BNE :3
  231.           INC ZPage1+1
  232. :3        INC Temp4
  233.           DEX
  234.           BPL :2
  235.           INC Temp2
  236.           INC Temp2
  237.           LDA Temp2
  238.           CMP #40
  239.           BNE :4
  240.           Mov #$00       ;Temp2
  241.           Add #10        ;Temp3
  242. :4        INC Temp1
  243.           LDA Temp1
  244.           CMP #$60
  245.           BNE :1
  246.           RTS
  247.  
  248. * The following three routines are the editing options:
  249.  
  250. * UpVert  - Scrolls the designated character one row up
  251. * Inverse - Inverts the entire designated character
  252. * Upside  - Turns the specified character up-side down
  253.  
  254. UpVert    Set Common2+1  ;UpVert1
  255.           JMP Common
  256. Inverse   Set Common2+1  ;Inverse1
  257.           JMP Common
  258. Upside    Set Common2+1  ;Upside1
  259. Common    Mov #$00       ;Temp1
  260.           STA Temp2
  261.           LDX #$5F
  262. Common1   TXA
  263.           PHA
  264. Common2   JSR $FFFF
  265.           INC Temp2
  266.           INC Temp2
  267.           LDA Temp2
  268.           CMP #40
  269.           BNE :1
  270.           Mov #$00       ;Temp2
  271.           Add #10        ;Temp1
  272. :1        PLA
  273.           TAX
  274.           DEX
  275.           BPL Common1
  276.           JSR CreateN
  277.           JSR Convert
  278.           JMP ShowSet
  279.  
  280. UpVert1   LDY Temp1
  281.           INY
  282.           STY Temp3
  283.           DEY
  284.           JSR SetPg1Y
  285.           LDY Temp2
  286.           LDA (ZPage1),Y
  287.           PHA
  288.           LDX #$06
  289. :1        LDY Temp3
  290.           Mov YHiresL,Y  ;ZPage2
  291.           Mov YHiresH,Y  ;ZPage2+1
  292.           LDY Temp2
  293.           Mov (ZPage2),Y ;(ZPage1),Y
  294.           Mov ZPage2     ;ZPage1
  295.           Mov ZPage2+1   ;ZPage1+1
  296.           INC Temp3
  297.           DEX
  298.           BPL :1
  299.           PLA
  300.           STA (ZPage2),Y
  301.           RTS
  302.  
  303. Inverse1  Mov Temp1      ;Temp3
  304.           LDX #$07
  305. :1        LDY Temp3
  306.           JSR SetPg1Y
  307.           LDY Temp2
  308.           LDA (ZPage1),Y
  309.           EOR #$7F
  310.           STA (ZPage1),Y
  311.           INC Temp3
  312.           DEX
  313.           BPL :1
  314.           RTS
  315.  
  316. Upside1   Mov Temp1      ;Temp4
  317.           CLC
  318.           ADC #$07
  319.           STA Temp3
  320.           LDX #$03
  321. :1        LDY Temp4
  322.           JSR SetPg1Y
  323.           LDY Temp3
  324.           Mov YHiresL,Y  ;ZPage2
  325.           Mov YHiresH,Y  ;ZPage2+1
  326.           LDY Temp2
  327.           LDA (ZPage1),Y
  328.           PHA
  329.           Mov (ZPage2),Y ;(ZPage1),Y
  330.           PLA
  331.           STA (ZPage2),Y
  332.           INC Temp4
  333.           DEC Temp3
  334.           DEX
  335.           BPL :1
  336.           RTS
  337.  
  338. * ShowSet - A small routine which displays the entire
  339. *           character set in a non-proportional fashion
  340. *           for clarity then displays a single line of
  341. *           sample character generation for viewing.
  342.  
  343. ShowSet   Mov #$00       ;Temp1
  344.           STA Temp2
  345.           Mov #32        ;Temp3
  346.           LDA PrintFlg
  347.           PHA
  348.           Mov #$02       ;PrintFlg
  349. :1        Mov Temp1      ;COUTHorH
  350.           Mov Temp2      ;COUTVert
  351.           Mov #$00       ;COUTHorL
  352.           LDA Temp3
  353.           JSR JMPCout
  354.           LDA #" "
  355.           JSR JMPCout
  356.           JSR JMPCout
  357.           INC Temp1
  358.           INC Temp1
  359.           LDA Temp1
  360.           CMP #40
  361.           BNE :2
  362.           Mov #$00       ;Temp1
  363.           Add #10        ;Temp2
  364. :2        INC Temp3
  365.           LDA Temp3
  366.           CMP #$80
  367.           BNE :1
  368.           Mov #60        ;COUTVert
  369.           Mov #65        ;Temp4
  370.           Mov #$00       ;COUTHorH
  371.           STA COUTHorL
  372. :3        LDA Temp4
  373.           BEQ :4
  374.           JSR JMPCout
  375.           CLC
  376.           ADC #32
  377.           JSR JMPCout
  378.           INC Temp4
  379.           LDA COUTHorH
  380.           CMP #36
  381.           BLT :3
  382. :4        LDA #" "
  383.           JSR JMPCout
  384.           LDA COUTHorH
  385.           CMP #39
  386.           BGE :4
  387. :5        PLA
  388.           STA PrintFlg
  389.           RTS
  390.  
  391. * Magnify - This section produces the magnified image of
  392. *           a specified character at the bottom left of
  393. *           the screen.
  394.  
  395. Magnify   JSR Locate
  396.           Mov #132       ;COUTVert
  397.           Mov #$07       ;Temp2
  398. :1        LDY Temp2
  399.           Mov (ZPage1),Y ;COUTChar
  400.           JSR :3
  401.           Mov #$06       ;Temp1
  402. :2        LDA Temp1
  403.           TAY
  404.           CLC
  405.           ADC #$05
  406.           STA COUTHorH
  407.           Mov DisTable,Y ;COUTChar
  408.           JSR :5
  409.           DEC Temp1
  410.           BPL :2
  411.           LDA COUTVert
  412.           SEC
  413.           SBC #$07
  414.           STA COUTVert
  415.           DEC Temp2
  416.           BPL :1
  417.           RTS
  418. :3        LDX #$07
  419. :4        LDA #$80
  420.           AND COUTChar
  421.           STA DisTable,X
  422.           ASL COUTChar
  423.           DEX
  424.           BPL :4
  425.           RTS
  426. :5        LDA COUTChar
  427.           BEQ :6
  428.           LDA #$07
  429. :6        CLC
  430.           ADC #<DotTable
  431.           STA :8+1
  432.           LDA #>DotTable
  433.           ADC #$00
  434.           STA :8+2
  435.           LDX #$06
  436.           LDY COUTVert
  437. :7        LDA YHiresL,Y
  438.           CLC
  439.           ADC COUTHorH
  440.           STA :9+1
  441.           Mov YHiresH,Y  ;:9+2
  442. :8        LDA $FFFF
  443. :9        STA $FFFF
  444.           INC :8+1
  445.           BNE :0
  446.           INC :8+2
  447. :0        INY
  448.           DEX
  449.           BPL :7
  450.           RTS
  451.  
  452. * Cursor - This is the keypress routine which flashes the
  453. *          HIRES cursor until a key is pressed then
  454. *          returns control to BASIC.
  455.  
  456. Cursor    JSR :2
  457.           JSR :4
  458.           BCS :1
  459.           JSR :2
  460.           JSR :4
  461.           BCC Cursor
  462.           RTS
  463. :1        JSR :2
  464.           RTS
  465. :2        LDX COUTVert
  466.           Mov COUTChar   ;Temp1
  467. :3        Mov YHiresL,X  ;ZPage1
  468.           Mov YHiresH,X  ;ZPage1+1
  469.           LDY COUTHorH
  470.           LDA #$7F
  471.           EOR (ZPage1),Y
  472.           STA (ZPage1),Y
  473.           INX
  474.           DEC Temp1
  475.           BNE :3
  476.           RTS
  477. :4        LDX #$00
  478. :5        LDA $C000
  479.           BMI :6
  480.           DEX
  481.           BNE :5
  482.           CLC
  483.           RTS
  484. :6        SEC
  485.           RTS
  486.  
  487. * Toggle - Toggles the status of particular bits of the
  488. *          character as required by the editor.
  489.  
  490. Toggle    JSR Locate
  491.           LDY COUTHorH
  492.           LDA BitTable,Y
  493.           LDY COUTVert
  494.           EOR (ZPage1),Y
  495.           STA (ZPage1),Y
  496.           JMP Magnify
  497.  
  498. * Locate - This routine sets ZPage1 to point to the
  499. *          specified character in Table3b (the non-prop.
  500. *          table) for further indexed access.
  501.  
  502. Locate    Set ZPage1     ;Table3b
  503.           LDX COUTChar
  504.           BEQ :3
  505. :1        Add #$08       ;ZPage1
  506.           BCC :2
  507.           INC ZPage1+1
  508. :2        DEX
  509.           BNE :1
  510. :3        RTS
  511.  
  512. * SetPg1Y - A tiny subroutine for code size optimization.
  513.  
  514. SetPg1Y   Mov YHiresL,Y  ;ZPage1
  515.           Mov YHiresH,Y  ;ZPage1+1
  516.           RTS
  517.  
  518. BitTable  HEX 01020408102040    ;Bit mask table
  519. DotTable  HEX 0000081C080000    ;Magnify characters
  520.           HEX 3E7F7F7F7F7F3E
  521.